<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * @fileoverview 上传方式类的基类
<span class='line'>  3</span>  * @author: 剑平（明河）&lt;minghe36@126.com>,紫英&lt;daxingplay@gmail.com>
<span class='line'>  4</span>  **/</span><span class="WHIT">
<span class='line'>  5</span> </span><span class="NAME">KISSY.add</span><span class="PUNC">(</span><span class="STRN">'gallery/form/1.0/uploader/type/base'</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">S</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Base</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  6</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">EMPTY</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="NAME">$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Node.all</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  7</span> 
<span class='line'>  8</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>  9</span>      * @name UploadType
<span class='line'> 10</span>      * @class 上传方式类的基类，定义通用的事件和方法，一般不直接监听此类的事件
<span class='line'> 11</span>      * @constructor
<span class='line'> 12</span>      * @extends Base
<span class='line'> 13</span>      * @param {Object} config 组件配置（下面的参数为配置项，配置会写入属性，详细的配置说明请看属性部分）
<span class='line'> 14</span>      * @param {String} config.action *，服务器端路径
<span class='line'> 15</span>      * @param {Object} config.data 传送给服务器端的参数集合（会被转成hidden元素post到服务器端）
<span class='line'> 16</span>      *
<span class='line'> 17</span>      */</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">UploadType</span><span class="PUNC">(</span><span class="NAME">config</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">        </span><span class="COMM">//调用父类构造函数</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">        </span><span class="NAME">UploadType.superclass.constructor.call</span><span class="PUNC">(</span><span class="NAME">self</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="WHIT">    </span><span class="NAME">S.mix</span><span class="PUNC">(</span><span class="NAME">UploadType</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">/** @lends UploadType*/</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'> 26</span>          * 事件列表
<span class='line'> 27</span>          */</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">        </span><span class="NAME">event</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">            </span><span class="COMM">//开始上传后触发</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">            </span><span class="NAME">START</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'start'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">            </span><span class="COMM">//停止上传后触发</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">            </span><span class="NAME">STOP</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'stop'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">            </span><span class="COMM">//成功请求</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">            </span><span class="NAME">SUCCESS</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'success'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">            </span><span class="COMM">//上传失败后触发</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">            </span><span class="NAME">ERROR</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'error'</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> 
<span class='line'> 40</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 41</span>      * @name UploadType#start
<span class='line'> 42</span>      * @desc  开始上传后触发
<span class='line'> 43</span>      * @event
<span class='line'> 44</span>      */</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 46</span>      * @name UploadType#stop
<span class='line'> 47</span>      * @desc  停止上传后触发
<span class='line'> 48</span>      * @event
<span class='line'> 49</span>      */</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 51</span>      * @name UploadType#success
<span class='line'> 52</span>      * @desc  上传成功后触发
<span class='line'> 53</span>      * @event
<span class='line'> 54</span>      */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 56</span>      * @name UploadType#error
<span class='line'> 57</span>      * @desc  上传失败后触发
<span class='line'> 58</span>      * @event
<span class='line'> 59</span>      */</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="COMM">//继承于Base，属性getter和setter委托于Base处理</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="NAME">S.extend</span><span class="PUNC">(</span><span class="NAME">UploadType</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Base</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">/** @lends UploadType.prototype*/</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'> 63</span>          * 上传文件
<span class='line'> 64</span>          */</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">        </span><span class="NAME">upload</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> 
<span class='line'> 67</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'> 69</span>          * 停止上传
<span class='line'> 70</span>          */</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">        </span><span class="NAME">stop</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">            </span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">ATTRS</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @lends UploadType.prototype*/</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'> 76</span>          * 服务器端路径
<span class='line'> 77</span>          * @type String
<span class='line'> 78</span>          * @default ""
<span class='line'> 79</span>          */</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">        </span><span class="NAME">action</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">EMPTY</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'> 82</span>          * 传送给服务器端的参数集合（会被转成hidden元素post到服务器端）
<span class='line'> 83</span>          * @type Object
<span class='line'> 84</span>          * @default {}
<span class='line'> 85</span>          */</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">        </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> 
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">UploadType</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">requires</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="STRN">'node'</span><span class="PUNC">,</span><span class="STRN">'base'</span><span class="PUNC">]</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>